package com.lucas.servlet.chapter5.controller;

import com.lucas.servlet.chapter5.util.JwtUtil;
import org.springframework.security.core.userdetails.User;
import org.springframework.web.bind.annotation.*;

@RestController
public class UserController {
    @RequestMapping (value = "/login", method = {RequestMethod.POST, RequestMethod.GET})
    public String login(String username, String password) {
//验证账号密码
//TODO
        User user = (User) User.withUsername("张三")
                .username("张三")
                .password("123")
                .authorities("USER")
                .build();
//返回token
        return JwtUtil.createJwt(user);
    }
}
